package someidea;


import it.unisa.dia.gas.jpbc.Element;
import secretSharing.ThresholdSecretSharing;

import java.math.BigInteger;
import java.security.SecureRandom;

public class DSC {
    Setup setup = new Setup();

    public Element choiceSecretKey(){

        Element sk = this.setup.Zq.newRandomElement();
        return sk;
    }

    public byte[] sk2Byte( Element sk){
        return sk.toBytes();
    }

    public Element sk2Element(byte[] sk_byte){
        Element sk = this.setup.Zq.newElementFromBytes(sk_byte);
        return sk;
    }

    public byte[][] splitKey(Element sk,Integer party, Integer threshold){
        byte[] sk_byte = sk2Byte(sk);
        ThresholdSecretSharing tss = new ThresholdSecretSharing();
        byte[][] skShares = tss.createShares(sk_byte,party,threshold,new SecureRandom());

        return skShares;
    }


}
